package com.example.manager;

import org.springframework.stereotype.Service;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 线程池管理器
 */
@Service
public class ThreadPoolManager {
    private static final int THREAD_POOL_SIZE = 10;
    private static final ExecutorService executor = Executors.newFixedThreadPool(THREAD_POOL_SIZE);

    // 提交任务到线程池中执行
    public void submitTask(Runnable task) {
        executor.submit(task);
    }

    // 关闭线程池
    public void shutdown() {
        executor.shutdown();
    }
}
